<template>
	<view class="message">
		<!-- #ifndef MP-TOUTIAO -->
		<view class="fixedTop">
			<u-status-bar></u-status-bar>
			<view style="height: 88rpx;display: flex;align-items: center;justify-content: center;">
				<view>消息</view>
			</view>
		</view>
		<!-- #endif -->
		<view v-if="msgList.length" class="msgList">
			<view class="item" v-for="(v,i) in msgList" :key="i" @click="goMsg(v)">
				<view class="left">
					<view class="avatar">
						<view v-if="v.no_read" class="dot">
							{{v.no_read < 99 ? v.no_read : "99"}}
						</view>
						<image :src="v.another_user.avatar" mode="scaleToFill">
						</image>
					</view>
					<view class="info">
						<view class="name u-line-1">{{v.another_user.nickname}}</view>
						<view class="msg u-line-1">{{v.last_message_data.content}}</view>
					</view>
				</view>
				<view class="right">
					{{v.created_at}}
				</view>
			</view>
		</view>
		<nullPage v-else title="暂无消息"></nullPage>

		<g-tab-bar :select="2"></g-tab-bar>
	</view>
</template>

<script>
	import {
		mapState
	} from "vuex";
	import nullPage from "@/components/nullPage.vue"
	export default {
		components: {
			nullPage
		},
		data() {
			return {

			}
		},
		computed: {
			...mapState(["msgList"]),
		},
		onShow() {
			this.$store.dispatch("messageList")
		},
		onLoad() {

		},
		methods: {
			async goMsg(value) {
				this.$store.state.message_id = value.id
				this.navigateTo(
					`/pages/index/privateMessage?uid=${value.another_user.id}`)
			},
		}
	}
</script>

<style scoped lang="scss">
	.message {
		// #ifdef MP-WEIXIN
		padding-top: 184rpx;
		// #endif
		// #ifdef H5
		padding-top: 88rpx;

		// #endif
		.fixedTop {
			position: fixed;
			top: 0;
			left: 0;
			z-index: 99;
			width: 100%;
			background-color: #fff;

			view {
				font-weight: bold;
				font-size: 32rpx;
				color: #333333;
			}
		}

		.msgList {
			padding: 0 32rpx;

			.item {
				display: flex;
				align-items: center;
				justify-content: space-between;
				height: 128rpx;
				border-bottom: 2rpx solid rgba(0, 0, 0, 0.03);

				.left {
					display: flex;
					align-items: center;

					.avatar {
						position: relative;
						width: 88rpx;
						height: 88rpx;

						.dot {
							position: absolute;
							top: 0;
							right: 0;
							z-index: 99;
							padding: 0 8rpx;
							height: 28rpx;
							background: #FF504A;
							border-radius: 50%;
							border: 1rpx solid #FFFFFF;
							font-weight: bold;
							font-size: 20rpx;
							color: #FFFFFF;
						}

						image {
							width: 88rpx;
							height: 88rpx;
							border-radius: 50%;
						}
					}

					.info {
						padding: 0 16rpx;

						.name {
							font-weight: bold;
							font-size: 28rpx;
							color: #333333;
						}

						.msg {
							padding-top: 12rpx;
							font-weight: bold;
							font-size: 22rpx;
							color: #8D8F90;
						}
					}
				}

				.right {
					font-weight: 500;
					font-size: 20rpx;
					color: #8D8F90;
				}
			}
		}
	}
</style>